********************************************************************************
/**Replication file for:
"COVID-19 Information, demand and willingness to pay for protective gear in the UK"
by S. Oreffice and C. Quintana-Domeque (c.quintana-domeque@exeter.ac.uk)
Last revision: July 14, 2021
*/
********************************************************************************

clear all

version 16.0

global path "your folder"

use "$path\data\dataset_rep_Info_WTP.dta", clear

********************************************************************************

timer on 1

********************************************************************************

***Informational treatments***

gen T1=1 if arm==1
replace T1=0 if arm!=1

gen T2=1 if arm==2
replace T2=0 if arm!=2

*************************
 
gen ARM="Control" if arm==0
replace ARM="Info on tested people" if arm==1
replace ARM="Info on deaths" if arm==2

********************************************************************************

gen white=1 if ethnicity=="White"
replace white=0 if ethnicity!="White"

tab region, gen(reg_)

gen marcoh=1 if (marital=="Married"|marital=="Never Married and Cohabiting")
replace marcoh=0 if (marital!="Married"&marital!="Never Married and Cohabiting")

gen university=1 if education=="University"
replace university=0 if education!="University"

gen double ly=log(y)

global standardcontrols female age white reg_1 reg_2 reg_3 reg_4 reg_5 reg_6 reg_7 reg_8 reg_9 reg_10 reg_11 marcoh hhsize university ly 

********************************************************************************

********************************************************************************
**Table 1: Estimated Demands and WTP
********************************************************************************

reg hs phs if arm==0, r
reg fm pfm if arm==0, r
reg g pg if arm==0, r
logit hs phs if arm==0 
logit fm pfm if arm==0
logit g pg if arm==0

***WTP (LPM)
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[phs]), reps(1000) nodots seed (11042020): reg hs phs if arm==0, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pfm]), reps(1000) nodots seed (11042020): reg fm pfm if arm==0, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pg]), reps(1000) nodots seed (11042020): reg g pg if arm==0, r

***WTP (Logit)
bootstrap (-_b[_cons]/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==0
bootstrap (-_b[_cons]/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==0
bootstrap (-_b[_cons]/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==0

***Conditional WTP (Logit)
bootstrap (-ln(1+exp(_b[_cons]))/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==0
bootstrap (-ln(1+exp(_b[_cons]))/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==0
bootstrap (-ln(1+exp(_b[_cons]))/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==0

********************************************************************************
**Table 2: OLS regressions of protective gear on T1 and T2
********************************************************************************

*************Individual tests

reg hs T1 T2, r

test T1 = T2 = 0
test T1 = T2

ciplot hs, by(ARM)

reg fm T1 T2, r

test T1 = T2 = 0
test T1 = T2

ciplot fm, by(ARM)

reg g T1 T2, r

test T1 = T2 = 0
test T1 = T2

ciplot g, by(ARM)

*************Simultaneous tests

reg hs T1 T2 
estimates store MH
reg fm T1 T2 
estimates store MF
reg g T1 T2 
estimates store MG

suest MH MF MG, vce(robust)
test [MH_mean]T1
test [MH_mean]T2, accumulate
test [MF_mean]T1, accumulate
test [MF_mean]T2, accumulate
test [MG_mean]T1, accumulate
test [MG_mean]T2, accumulate


********************************************************************************
**Table 3: WTP by treatment arm
********************************************************************************

******************WTP by arm (LPM)

bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[phs]), reps(1000) nodots seed (11042020): reg hs phs if arm==1, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[phs]), reps(1000) nodots seed (11042020): reg hs phs if arm==2, r

bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pfm]), reps(1000) nodots seed (11042020): reg fm pfm if arm==1, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pfm]), reps(1000) nodots seed (11042020): reg fm pfm if arm==2, r

bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pg]), reps(1000) nodots seed (11042020): reg g pg if arm==1, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pg]), reps(1000) nodots seed (11042020): reg g pg if arm==2, r

******************WTP by arm (Logit)
 
bootstrap (-_b[_cons]/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==1
bootstrap (-_b[_cons]/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==2
 
bootstrap (-_b[_cons]/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==1
bootstrap (-_b[_cons]/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==2

bootstrap (-_b[_cons]/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==1
bootstrap (-_b[_cons]/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==2 
 
******************Conditional WTP by arm (Logit)

bootstrap (-ln(1+exp(_b[_cons]))/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==1
bootstrap (-ln(1+exp(_b[_cons]))/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==2
 
bootstrap (-ln(1+exp(_b[_cons]))/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==1
bootstrap (-ln(1+exp(_b[_cons]))/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==2

bootstrap (-ln(1+exp(_b[_cons]))/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==1
bootstrap (-ln(1+exp(_b[_cons]))/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==2 


********************************************************************************
**Figure 1: Non-parametric stated demand for disposable face masks by treatment arm.
********************************************************************************

mean fm, over(pfm arm)
marginsplot

********************************************************************************
*********************SUPPLEMENTARY MATERIAL*************************************
********************************************************************************

///////////////////////////
***Supplementary Tables***
//////////////////////////

********************************************************************************
***Table S1. Summary statistics
********************************************************************************
sum female age white university y hands facem gloves phs pfm pg hs fm g

********************************************************************************
***Table S2. Estimated demands with control variables
********************************************************************************

reg hs phs $standardcontrols hands if arm==0, r
test $standardcontrols hands

reg fm pfm $standardcontrols facem if arm==0, r
test $standardcontrols facem

reg g pg $standardcontrols gloves if arm==0, r
test $standardcontrols gloves

logit hs phs $standardcontrols hands if arm==0 
test $standardcontrols hands
  
logit fm pfm $standardcontrols facem if arm==0
test $standardcontrols facem

logit g pg $standardcontrols gloves if arm==0
test $standardcontrols gloves

********************************************************************************
***Table S3. Estimated WTP by sex
********************************************************************************

gen Fphs=female*phs
gen Fpfm=female*pfm
gen Fpg=female*pg

******************WTP by sex (LPM)

reg hs phs female Fphs if arm==0, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[phs]) (0.5*(_b[_cons]+_b[female])*(-_b[_cons]-_b[female])/(_b[phs]+_b[Fphs])) , reps(1000) nodots seed (11042020): reg hs phs female Fphs if arm==0, r

reg fm pfm female Fpfm if arm==0, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pfm]) (0.5*(_b[_cons]+_b[female])*(-_b[_cons]-_b[female])/(_b[pfm]+_b[Fpfm])) , reps(1000) nodots seed (11042020): reg fm pfm female Fpfm if arm==0, r

reg g pg female Fpg if arm==0, r
bootstrap (0.5*_b[_cons]*(-_b[_cons])/_b[pg]) (0.5*(_b[_cons]+_b[female])*(-_b[_cons]-_b[female])/(_b[pg]+_b[Fpg])) , reps(1000) nodots seed (11042020): reg g pg female Fpg if arm==0, r

******************WTP by sex (Logit)

bootstrap (-_b[_cons]/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==0 & female==0
bootstrap (-_b[_cons]/_b[phs]), reps(1000) nodots seed (11042020): logit hs phs  if arm==0 & female==1

bootstrap (-_b[_cons]/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==0 & female==0
bootstrap (-_b[_cons]/_b[pfm]), reps(1000) nodots seed (11042020): logit fm pfm  if arm==0 & female==1

bootstrap (-_b[_cons]/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==0 & female==0
bootstrap (-_b[_cons]/_b[pg]), reps(1000) nodots seed (11042020): logit g pg  if arm==0 & female==1

********************************************************************************
***Table S4. Randomisation check
********************************************************************************

mlogit arm gloves facem hands female age white reg_1-reg_11 marcoh hhsize university ly phs pfm pg  
test [0]gloves = [0]facem = [0]hands = [0]female = [0]age = [0]white = [0]reg_1 = [0]reg_2 = [0]reg_3 = [0]reg_4 = [0]reg_5 = [0]reg_6 = [0]reg_7 = [0]reg_8 = [0]reg_9 = [0]reg_10 = [0]reg_11 = [0]marcoh = [0]hhsize = [0]university = [0]ly = [0]phs = [0]pfm = [0]pg = [1]gloves = [1]facem = [1]hands = [1]female = [1]age = [1]white = [1]reg_1 = [1]reg_2 = [1]reg_3 = [1]reg_4 = [1]reg_5 = [1]reg_6 = [1]reg_7 = [1]reg_8 = [1]reg_9 = [1]reg_10 = [1]reg_11 = [1]marcoh = [1]hhsize = [1]university = [1]ly = [1]phs = [1]pfm = [1]pg = 0

 foreach var of varlist hands facem gloves female age white reg_1-reg_11 marcoh hhsize university ly phs pfm pg {
                reg `var' T1 T2, r
				display _b[_cons] + _b[T1]
				display _b[_cons] + _b[T2]
				test T1 = T2 = 0
				        }
						
**excluding prices:

mlogit arm gloves facem hands female age white reg_1-reg_11 marcoh hhsize university ly 

test [0]gloves = [0]facem = [0]hands = [0]female = [0]age = [0]white = [0]reg_1 = [0]reg_2 = [0]reg_3 = [0]reg_4 = [0]reg_5 = [0]reg_6 = [0]reg_7 = [0]reg_8 = [0]reg_9 = [0]reg_10 = [0]reg_11 = [0]marcoh = [0]hhsize = [0]university = [0]ly = [1]gloves = [1]facem = [1]hands = [1]female = [1]age = [1]white = [1]reg_1 = [1]reg_2 = [1]reg_3 = [1]reg_4 = [1]reg_5 = [1]reg_6 = [1]reg_7 = [1]reg_8 = [1]reg_9 = [1]reg_10 = [1]reg_11 = [1]marcoh = [1]hhsize = [1]university = [1]ly = 0

						
********************************************************************************
***Table S5. Average treatment effects of information using a Logit probability model
********************************************************************************

logit hs T1 T2 

margins, dydx(T1)
margins, dydx(T2)

logit fm T1 T2 

margins, dydx(T1)
margins, dydx(T2)

logit g T1 T2 

margins, dydx(T1)
margins, dydx(T2) 

********************************************************************************
***Table S6. OLS regressions of hand sanitiser, face masks or gloves on T1, T2, female and interactions
********************************************************************************
 
gen FT1=female*T1
gen FT2=female*T2

***Parametric analysis

reg hs T1 T2 female FT1 FT2, r
reg fm T1 T2 female FT1 FT2, r
reg g T1 T2 female FT1 FT2, r 

********************************************************************************
***Table S7. OLS regressions of fraction donated to Age UK, BLF, Samaritans, Women's Aid or None on T1 and T2
********************************************************************************

reg fAgeUK T1 T2, r

test T1 = T2 = 0
test T1 = T2

reg fBLF T1 T2, r

test T1 = T2 = 0
test T1 = T2

reg fSam T1 T2, r

test T1 = T2 = 0
test T1 = T2

reg fWomenA T1 T2, r

test T1 = T2 = 0
test T1 = T2

reg fnone T1 T2, r

test T1 = T2 = 0
test T1 = T2

***simultaneous tests 

reg fAgeUK T1 T2
estimates store D1
reg fBLF T1 T2
estimates store D2
reg fSam T1 T2
estimates store D3
reg fWomenA T1 T2
estimates store D4
 
suest D1 D2 D3 D4, vce(robust)
test [D1_mean]T1
test [D1_mean]T2, accumulate
test [D2_mean]T1, accumulate
test [D2_mean]T2, accumulate
test [D3_mean]T1, accumulate
test [D3_mean]T2, accumulate
test [D4_mean]T1, accumulate
test [D4_mean]T2, accumulate
 
********************************************************************************
***Table S8. Average treatment effects of information using a Fractional Logit Model.
********************************************************************************

fracreg logit fAgeUK T1 T2 

margins, dydx(T1)
margins, dydx(T2)

fracreg logit fBLF T1 T2 

margins, dydx(T1)
margins, dydx(T2)

fracreg logit fSam T1 T2 

margins, dydx(T1)
margins, dydx(T2)

fracreg logit fWomenA T1 T2 

margins, dydx(T1)
margins, dydx(T2)

fracreg logit fnone T1 T2 

margins, dydx(T1)
margins, dydx(T2)

********************************************************************************
***Table S9. OLS regressions of fraction donated to Age UK, BLF, Samaritans, Women's Aid or None on T1, T2, female and interactions
********************************************************************************

reg fAgeUK T1 T2 female FT1 FT2, r
reg fBLF T1 T2 female FT1 FT2, r
reg fSam T1 T2 female FT1 FT2, r
reg fWomenA T1 T2 female FT1 FT2, r
reg fnone T1 T2 female FT1 FT2, r

***************Simultaneous test of main treatment effects**********************

reg fAgeUK T1 T2 female FT1 FT2
estimates store D1
reg fBLF T1 T2 female FT1 FT2
estimates store D2
reg fSam T1 T2 female FT1 FT2
estimates store D3
reg fWomenA T1 T2 female FT1 FT2
estimates store D4

suest D1 D2 D3 D4, vce(robust)
test [D1_mean]T1
test [D1_mean]T2, accumulate
test [D2_mean]T1, accumulate
test [D2_mean]T2, accumulate
test [D3_mean]T1, accumulate
test [D3_mean]T2, accumulate
test [D4_mean]T1, accumulate
test [D4_mean]T2, accumulate

 
//////////////////////
***Supplementary Figures***
/////////////////////

/* We make use of the following Stata module:
 
CIPLOT: Stata module for plots of confidence intervals

https://ideas.repec.org/c/boc/bocode/s431202.html

Nicholas J. Cox, 2003. "CIPLOT: Stata module for plots of confidence intervals," Statistical Software Components S431202, Boston College Department of Economics, revised 15 Aug 2011.
 
*/ 

********************************************************************************
***Figure S1 (this was the last screen of the survey).
********************************************************************************

******************************************************************************** 
***Figure S2. 
********************************************************************************
ciplot hs, by(ARM)

********************************************************************************
***Figure S3. 
********************************************************************************
ciplot fm, by(ARM)

********************************************************************************
***Figure S4. 
********************************************************************************
ciplot g, by(ARM)

********************************************************************************
***Figure S5.  
********************************************************************************
mean hs, over(phs arm)
marginsplot

********************************************************************************
***Figure S6.  
********************************************************************************
mean g, over(pg arm)
marginsplot 

********************************************************************************
***Figure S7.
********************************************************************************
mean hs, over(phs arm female)
marginsplot

********************************************************************************
***Figure S8.
********************************************************************************
mean fm, over(pfm arm female)
marginsplot

********************************************************************************
***Figure S9.
********************************************************************************
mean g, over(pg arm female)
marginsplot 

********************************************************************************
********************************************************************************

timer off 1

timer list

********************************************************************************
********************************************************************************